#ifndef _DEBUG_PRINT_H_
#define _DEBUG_PRINT_H_

#include "common_def.h"
#include "rtc.h"
#include <stdarg.h>

enum DEBUG_TARGET_T
{
  DEBUG_TO_UART_0,
  DEBUG_TO_UART_1
};
typedef enum DEBUG_TARGET_T DEBUG_TARGET_T;

DEBUG_TARGET_T debug_select_uart(DEBUG_TARGET_T uart);

// debug is enabled
void debug_puts(const uint8* str);
void debug_vprintf(const uint8* fmt, va_list vl);
void debug_printf(const uint8* fmt, ...);
void debug_print_int(uint16 val);
void debug_print_uint32(uint32 val);
void debug_print_hex(uint16 val);
void debug_print_float(float val);
void debug_print_time(DATE_TIME_T* time);
void debug_putc(uint8 c);
void debug_echo(uint8 c);   // echo char to terminal
void mem_dump(uint8* ptr, uint16 size);

#define ASSERT(x) do { \
  if (!(x)) { \
    debug_printf((const uint8*)"%s: %d: Assert failed: %s\n", __FILE__, __LINE__, #x); \
    RESET_DEVICE(); \
  } \
} while (0)

#endif /* _DEBUG_PRINT_H_ */
